package com.meme.editor.level.define;


import java.util.Hashtable;
import java.util.List;
import java.util.Vector;

import com.meme.editor.EntityObject;
import com.meme.editor.level.Actor;
import com.meme.editor.level.LevelFile.ActorSet;

public class DefineFile extends EntityObject
{
	public static final String EntityName_ActorTemplateSet = "Actor Templates";

	public class ActorTemplateSet extends EntityObject
	{
		protected ActorTemplateSet () 
		{
			super (EntityName_ActorTemplateSet); 
			getPublicProperty (EntityObject.GroupName_Entity, EntityObject.PropertyName_Name).setEditable(false);
		}		
		
		@Override protected boolean isValidChild (EntityObject entity) 
		{ 
			return entity instanceof ActorTemplate; 
		}
	}
	
	ActorTemplateSet mActorTemplateSet = new ActorTemplateSet ();
	
	public ActorTemplateSet getActorTemplateSet ()
	{
		return mActorTemplateSet;
	}
	
//============================================================================	
	
	
	Hashtable <String, Parameter> mParameters = new Hashtable <String, Parameter> ();
	Hashtable <String, List<Parameter> > mItemLists = new Hashtable <String, List<Parameter> > ();
//	Hashtable <String, Sprite2dFile>
	Hashtable <String, PropertyDefineBlock> mPropertyDefBlocks = new Hashtable <String, PropertyDefineBlock> ();
	//Hashtable <String, ActorTemplate> mActorTemplates = new Hashtable <String, ActorTemplate> ();
	//List <ActorTemplate> mActorTemplateList = new Vector <ActorTemplate> ();
	
	
	
	public DefineFile ()
	{
		super ("DefineFile");
		
		//
		addChild (mActorTemplateSet);
	}
	
	@Override protected boolean isValidChild (EntityObject entity) 
	{ 
		return entity instanceof ActorTemplateSet; 
	}
	
	public void addParameters (List<Parameter> paramList)
	{
		for (Parameter param : paramList)
		{
			mParameters.put (param.getName(), param);
		}		
	}
	
	public Parameter getParameter (String name)
	{
		return mParameters.get (name);
	}
	
	public void addItemList (String name, List<Parameter> itemList)
	{
		mItemLists.put (name, itemList);
	}
	
	public List<Parameter> getItemList (String name)
	{
		return mItemLists.get (name);
	}

	
	public void addPropertyDefBlcks (List<PropertyDefineBlock> propertyDefBlocks)
	{
		for (PropertyDefineBlock block : propertyDefBlocks)
		{
			mPropertyDefBlocks.put (block.getName(), block);
		}
	}

	public PropertyDefineBlock getPropertyDefBlock (String name)
	{
		return mPropertyDefBlocks.get (name);
	}
	
//	public void addActorTemplate (String name, ActorTemplate actorTemplate)
//	{
//		mActorTemplates.put (name, actorTemplate);
//		mActorTemplateList.add (actorTemplate);
//	}
	
	public void addActorTemplate (ActorTemplate actorTemplate)
	{
		mActorTemplateSet.addChild (actorTemplate);
	}
	
	public ActorTemplate getActorTemplate (String name)
	{
		//return mActorTemplates.get (name);
		
		return (ActorTemplate) mActorTemplateSet.getChildByName (name);
	}
	
//	public List<ActorTemplate> getActorTemplateList ()
//	{
//		return mActorTemplateList;
//	}
	
	@Override
	public Object getProperty (String propertyName)
	{
		if (propertyName.equals("ItemLists"))
		{
			return mItemLists;
		}
		
		return super.getProperty (propertyName);
	}
}
